@extends('web.layouts.app')

@section('styles')
    <link rel="stylesheet" type="text/css" href="{{ asset('resources/web/css/index.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ asset('resources/web/css/ucenter.css')}}">
@endsection

@section('content')
    <div class="uc-wrap swrap mt20">
        <div class="uc-side L">
            <div class="uc-nav">
                <ul>
                    @include('web.user_center.menu')
                </ul>
            </div>
        </div>
        <div class="uc-main uc-mainbg R">
            <!--数据列表-->
            <div class="user-item-list redpacket-search">
                <h3 class="title">红包查询</h3>
                <div class="menu">
                    <a class="{{ $type==0?'active':'' }}" href="{{ action('UserCenter\UserCenterController@gift') }}">所有红包</a><span>|</span>
                    <a class="{{ $type==1?'active':'' }}" href="{{ action('UserCenter\UserCenterController@gift',[1]) }}">未使用</a><span>|</span>
                    <a class="{{ $type==2?'active':'' }}" href="{{ action('UserCenter\UserCenterController@gift',[2]) }}">已使用</a><span>|</span>
                    <a class="{{ $type==3?'active':'' }}" href="{{ action('UserCenter\UserCenterController@gift',[3]) }}">已失效</a>
                </div>
                <ul class="data-list redpacket-search-list">
                    <li class="th">
                        <div class="col-name">名称</div>
                        <div class="col-time">生效时间</div>
                        <div class="col-time">截止时间</div>
                        <div class="col-money">领取金额(元)</div>
                        <div class="col-rule">使用规则</div>
                        <div class="col-status">状态</div>
                    </li>
                    @foreach($gifts as $gift)
                        <li>
                            <div class="col-name">
                            <a title="{{$gift->name}}">
                                {{$gift->name}}
                            </a>
                            </div>
                            <div class="col-time">{{ $gift->begin_time??'--' }}</div>
                            <div class="col-time">{{ $gift->end_time??'--' }}</div>
                            <div class="col-money">{{ $gift->money??'--' }}</div>
                            <div class="col-rule">
                                {{ (\App\Admin\Eloquent\Code::findByCodeAndTypeId($gift->used_rule, 'gift_money_used_rule')['name'])??'--' }}:{{ floor($gift->used_rule_money) }}
                            </div>
                            <div class="col-status"><span class="green">
                                    @if($gift->status == 1)
                                        已使用
                                        @elseif($gift->status == 2)
                                        已过期
                                        @else
                                        未使用
                                    @endif
                                </span></div>
                        </li>
                    @endforeach
                </ul>
                <div class="uc-page-box text-right">
                    <span class="total">共 <em>{{$gifts->total()}}</em> 条数据</span>
                    @for($i=1;$i<=$gifts->lastPage();$i++)
                        <a class="{{$gifts->currentPage()==$i?"current":""}}" href="{{ $gifts->url($i) }}">{{ $i }}</a>
                    @endfor
                    <span>{{ $gifts->currentPage() }}/{{ $gifts->lastPage() }}页</span>
                </div>
            </div>

        </div>
    </div>
@endsection

@section('scripts')
    <script src="{{ asset('resources/web/js/index.js') }}"></script>
@endsection